package www.admin.service.impl;

import www.admin.model.Channel;

import javax.annotation.Resource;

import www.admin.dao.IChannelDao;

import org.springframework.stereotype.Service;

import www.admin.mybatis.Criteria;
import www.admin.service.IChannelService;
import www.admin.utils.Layui;
import www.admin.utils.MessageConstant;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import java.util.List;

/**
 * 
 * Channel
 * 
 **/

@Service
public class ChannelServiceImpl implements IChannelService{


	public Layui queryPage (Criteria<Channel> param){
		PageHelper.startPage(param.getStartIndex(), param.getPageSize());
		List<Channel> list = channelRepository.queryPage(param);
			PageInfo<Channel> paInfo = new PageInfo<Channel>(list);
	return Layui.data((int)paInfo.getTotal(), paInfo.getList()); }

	public Integer queryPageCount (Criteria<Channel> param){
		return (Integer) channelRepository.queryPageCount(param);
	}

	public Channel  queryEntity (String id ){
		return channelRepository.queryEntity(id);
	}

	public String deleteById (String id ){
		int result = channelRepository.deleteById(id);
			if ( result != 1) {
					return MessageConstant.USER_TYPE_7;
			}
			return null;
	}

	public String insert(Channel record ){
		int result = channelRepository.insert(record);
			if ( result != 1) { 
					return MessageConstant.USER_TYPE_10;
			}
			return null;
	}

	public String update (Criteria<Channel> param){
		int result = channelRepository.update(param);
			if ( result != 1) { 
					return MessageConstant.USER_TYPE_14;
			}
			return null;
	}
	
	@Override
	public List<Channel> queryPageList(Criteria<Channel> param) {
		return channelRepository.queryPage(param);
	}


	@Resource
	private IChannelDao channelRepository;

}